package jrobutt.room;

import jrobutt.*;

public class Particle extends GameObject
{
    private float life_timer;
    public boolean is_dead;
    
    public float xacc;
    public float yacc;
    
    /* assume life_duration > 0.0f */
    public Particle (float x, float y, float xspeed, float yspeed, float xacc, float yacc, float life_duration, GameSprite sprite)
    {
        super(x, y, sprite);
        this.xspeed = xspeed;
        this.yspeed = yspeed;
        this.xacc = xacc;
        this.yacc = yacc;
        
        this.life_timer = life_duration;
        
        this.is_dead = false;
    }
    
    public void update ()
    {
        if (life_timer > 0)
        {
            life_timer -= 1.0f;
            if (life_timer <= 0.0f)
            {
                is_dead = true;
            }
        }
        
        if (is_dead) return;
        
        xspeed += xacc;
        yspeed += yacc;
        
        super.update();
    }
}
